package models

import (
	"github.com/astaxie/beego/orm"
	"time"
)

type Cases struct {
	Id         int `orm:"auto"`
	Number     string
	Type       string
	Address    string
	Crime_at   time.Time
	Loss       string
	Describe   string
	Company_id int
	Created_at time.Time `orm:"auto_now_add,type(datetime)"`
	Updated_at time.Time `orm:"auto_now,type(datetime)"`
}

func CasesList(page int, limit int) ([]*Cases, int64) {
	cases := new(Cases)
	offset := (page - 1) * limit
	list := make([]*Cases, 0)
	total, _ := orm.NewOrm().QueryTable(cases).Count()
	orm.NewOrm().QueryTable(cases).Limit(limit, offset).All(&list)
	return list, total
}
